import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';

export default async function a004(fd: IFeidaoAiBrowserComponent) {
	// 左修改数据

	// 获取id
	const value = get(fd, 'cs') as { id: string, risk_level: string };
	console.log("++++++>", value);
	const id = value.id;
	console.log("id++++++>", id);
	const dj = value.risk_level;
	console.log("dj++++++>", dj);
	const risk_po_type_name = fd.data.node.querySelector<HTMLInputElement>('[data-name="risk_po_type_name"]').value;
	if (!risk_po_type_name) {
		alert('请输入风险点类型名称：');
		return;
	}
	const risk_level = fd.data.node.querySelector<HTMLOptionElement>('[data-name="risk_level"]');

	const ml = fd.data.node.querySelector('[data-feidao-actions="click:a003"]') as HTMLSelectElement;

	console.log("MMMMMMMMMMMMMMM==", ml);


	let val = '';
	if (risk_level) {
		val = ml.value;
	} else {
		val = dj;
	}



	const res = await nodejs<{ code: number; result: string; }>('risk_point/zj-000007/s002', {
		filter: {
			_id: id,
			risk_po_type_name,
			risk_level: val

		}
	});
	if (res.code === 1) {
		alert('成功！');
		window.location.reload();
	} else {
		alert('失败!');
	}
}
